package com.education.welco.controller;

import com.education.common.pojo.AjaxResult;
import com.education.welco.pojo.StudyResoursesDetail;
import com.education.welco.service.StudyResoursesDetailService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * zcp
 * 学生学习资源时长
 */
@RestController
@RequestMapping("/studyResoursesDetail")
public class StudyResoursesDetailController {

    public static final Logger LOGGER = LogManager.getLogger(StudyResoursesDetailController.class);

    @Autowired
    private StudyResoursesDetailService studyResoursesDetailService;


    /**
     * 新增数据
     *
     * @param studyResoursesDetail
     * @return
     */
    @PostMapping("/insert")
    public AjaxResult insert(@Valid StudyResoursesDetail studyResoursesDetail) {
        LOGGER.info("insert data {{}}", studyResoursesDetail);
        try {
            studyResoursesDetailService.insert(studyResoursesDetail);
            return AjaxResult.success();
        } catch (Exception e) {
            LOGGER.error("insert error", e);
            return AjaxResult.error();
        }
    }


}
